import com.sun.xml.internal.messaging.saaj.util.ByteInputStream;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

/**
 * @Classname T1
 * @Description T1
 * @Date 2023/8/4 18:21
 * @Author seven002
 */
public class T1 {
    public static void main(String[] args) throws IOException {
        String pathName = "C:\\Users\\seven002\\Desktop\\test\\1.txt";
        String payload = "hello baby hihihxxxxxxxxxxxxxxxi";
        ByteInputStream bis = new ByteInputStream(payload.getBytes(StandardCharsets.UTF_8), payload.getBytes(StandardCharsets.UTF_8).length);

        BufferedOutputStream out = null;
        BufferedInputStream in = new BufferedInputStream(bis);
        out = new BufferedOutputStream(new FileOutputStream(pathName));
        int len = -1;
        byte[] b = new byte[1024];
        while ((len = in.read(b)) != -1) {
            out.write(b, 0, len);
        }
        out.flush();

    }
}
